#include <iostream>

using namespace std;

int Gcd(int a, int b){
    if (b == 0){
        return a;
    }
    return Gcd(b, a % b);
}

/**
 * https://www.luogu.com.cn/problem/B4025
 */
int main() {
    int a,b;
    cin >> a >> b;
    cout << Gcd(a,b);
    return 0;
}